﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Cinchoo.Core.IO;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Xml;

namespace Cinchoo.Core.ETL
{
    [XmlRoot("ftpGet")]
    public class ChoETLFTPGetJobDef : ChoETLTaskDef
    {
        [ChoETLTaskDefPropertyInfo("REQUEST_URI_STRING", IsRequired = true)]
        [XmlAttribute("requestUriString")]
        public string RequestUriString { get; set; }

        [ChoETLTaskDefPropertyInfo("DEST_FILE_PATH")]
        [XmlAttribute("destinationFilePath")]
        public string DestinationFilePath { get; set; }

        [ChoETLTaskDefPropertyInfo("USER_NAME")]
        [XmlAttribute("userName")]
        public string UserName { get; set; }

        [ChoETLTaskDefPropertyInfo("PASSWORD")]
        [XmlAttribute("password")]
        public string Password { get; set; }

        [ChoETLTaskDefPropertyInfo("USE_PASSIVE")]
        [XmlAttribute("usePassive")]
        [DefaultValue(true)]
        public bool UsePassive { get; set; }

        [ChoETLTaskDefPropertyInfo("USE_BINARY")]
        [XmlAttribute("useBinary")]
        [DefaultValue(true)]
        public bool UseBinary { get; set; }

        protected override ChoETLTask Construct(ChoETLWorkflow workflow)
        {
            ChoGuard.ArgumentNotNullOrEmpty(RequestUriString, "RequestUriString");

            return new ChoETLFTPGetJob(RequestUriString, DestinationFilePath) { UserName = UserName, Password = Password, UsePassive = UsePassive, UseBinary = UseBinary }; 
        }
    }
}
